package com.zy.Conterller;


import com.zy.pojo.mm;
import com.zy.service.MmService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;

@Controller
@Slf4j
public class LoginCount {
@Resource
    private MmService mmService;
    @GetMapping("/login")
    public String login(){
        return "login";

    }
    @PostMapping("/login")
    public String login(String username, String password,Model model) {
        mm m =mmService.getMmByUserCode(username, password );
        if (m != null) {
            model.addAttribute("u", m);
            return "index";
        } else {
            model.addAttribute("loginErr", "用户密码错误");
            return "login";
        }
    }
}

